var uriUtil = require('../../utils/uri.js');
Page({
  data: {
    foods: [],
    sports:[],        //饮食列表
    uid: '',
    inputday:'',
    day:'',
    input:''
  },
  //页面加载
  onShow: function (options) {
    let that = this;
    let day = uriUtil.getDate()
    that.setData({
      inputday:day,
      day:day
    })
    this.sure();
  },
  //输入处理
  onInput:function (e) {
    let value = '2023.'+e.detail.value;
    console.log(e);
    this.setData({
      inputday: value
    });
  },
  //日期搜索
  sure:function () {
    let user = uriUtil.getUserInfo()
    let uid = user.id
    let that = this
    let day = that.data.inputday
    let url = uriUtil.BASE_URL
    wx.request({
      url: url+uriUtil.userFoodList,
      method:'get',
      data:{
        uid:uid,
        day:day
      },
      success:function(res){
        that.setData({
          day:day,
          foods:res.data,
          input:''
        })
      },

    })
    wx.request({
      url: url+uriUtil.userSportList,
      method:'get',
      data:{
        uid:uid,
        day:day
      },
      success:function(res){
        that.setData({
          sports:res.data
        })
      },
      false:function(){
        wx.showToast({
          title: '查询运动记录失败',
        });
      }
    })
  },

})